In order to ensure an acceptable level of quality tests are crucial in the software development process. Performing tests manually generally takes a great deal of time. However, the majority of software tests can be automated. Currently, there are various types of test automation frameworks available in the field that attempt to satisfy most of the requirements that usually are related to such kind of harnesses, such as tools integration, legacy tools support, ease of use, data integration, reporting features, shell script support, automatic environment setup, remote command execution, and so on.
One of the aspects where there are still deficiencies is related to the availability of test frameworks that allows to emulate missing runtime artifacts that the classes under tests require. Typical examples may be represented by classes that need to run queries toward a database; by classes that require a http session to handle UI events generated by a user; and so on.
In all such cases there may be problems when testing such classes since it may be difficult to reproduce all the required runtime artifacts. For these reasons several tools/frameworks exist on the market that allow to create mock objects to test classes without requiring that all their pre-requisite objects exists in the runtime environment where the class get instantiated and used.
Most of those tools provide ways to define mock objects by mean of a declarative language: in some cases (such as in the JMockit tool) this may be accomplished by leveraging Java annotations; in other cases (such as in AspectJ) this may be accomplished by providing a new language to be integrated with the Java one; etc.